﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.APP.Application.Command.Deep;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{
    /// <summary>
    /// API 控制器-深加工(班组) 
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeepController : ControllerBase
    {
        /// <summary>
        /// 中介者111
        /// </summary>
        /// <summary>
        /// 中介者222
        /// </summary>
        private readonly IMediator mediator;

        public DeepController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 班组信息新增
        /// </summary>
        /// <param name="command">参数</param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> DeepAdd(AddDeepCommand command)
        { 
            return mediator.Send(command);
        }
        
        /// <summary>
        /// 班组信息的显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Deep_Model>>> ShowDeep([FromQuery] ShowDeepCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 修改班组信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdateDeeep(UpdateDeepCommand command)
        {
            return mediator.Send(command);
        }


    }
}
